package com.bdzt.beidoubox.adapter;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bdzt.beidoubox.R;
import com.bdzt.beidoubox.entity.BoxInfo;
import com.bdzt.beidoubox.entity.FamilyInfo;

import java.util.List;

/**
 * Author： 默小二
 * E-mail: dear_mic@yeah.net
 * Date:  2017/4/12 14:12.
 * Desc:
 */

public class BoxListAdapter extends BaseAdapter {
    private Context context;
    private List<BoxInfo> list;
    private LayoutInflater inflater;

    public BoxListAdapter(List<BoxInfo> list, Context context) {
        this.list = list;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (holder == null || convertView.getTag() == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.box_item, parent, false);
            holder.et_boxName= (TextView) convertView.findViewById(R.id.et_boxName);
            holder.et_boxId= (TextView) convertView.findViewById(R.id.et_boxId);
            convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }

        holder.et_boxId.setText(list.get(position).getBoxID());
        holder.et_boxName.setText(list.get(position).getBoxName());

        return convertView;
    }


    class ViewHolder {
        private TextView et_boxId;
        private TextView et_boxName;

    }

}
